
const fs = require("fs");
const path = require("path");

function myrequire(file){
 
  function _require(exports, require, module, __dirname,__filename,file){
    // let test = {
    //   a: 111
    // }
    // console.log("我是a.js文件");
    // module.exports = test;
    let absolutePath = path.resolve(__dirname, file);
    let fileCode = fs.readFileSync(absolutePath).toString();
    eval(fileCode)
  }

  let module = {};
  let exports = module.exports = {};

  _require.call(exports,exports,myrequire,module,__dirname, __filename,file)

  return module.exports

}

const result = myrequire('./a.js')

console.log(result)